package com.jinyao.exploit.modules.gen.web;

import com.jinyao.exploit.modules.gen.entity.Table;
import com.jinyao.exploit.modules.gen.dao.ITableDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/***********************************************************************
 * 文件说明：自动生成控制器
 * 创建信息：李晋 2018-10-8 11:48
 * 变更履历： 
 ***********************************************************************/
@Controller
@RequestMapping(value = "${adminPath}/gen/table")
public class TableController {

  private String modules = "gen/";

  @Autowired
  private ITableDao tableDao;

  @RequestMapping(value = {"list", ""})
  public String list(Table table, Model model){
    model.addAttribute("tableList", tableDao.list(table));
    return modules + "list";
  }

  @RequestMapping(value = "form")
  public String form(){
    return modules + "form";
  }

  @RequestMapping(value = "save")
  public String save(Table table){
    tableDao.save(table);
    return "redirect:" + "/a" + "/gen/table";
  }
}
